﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aij1.Cms;
using Aij1.Model;
using DevExpress.Data.Filtering;

namespace Aij1
{
    /// <summary>
    /// 申请友情链接
    /// </summary>
    public partial class AskFriendLink : BasePage
    {
        protected G_FriendLink Link;
        protected string Tips;
        protected void Page_Load(object sender, EventArgs e)
        {
            PageName = "邀请友情链接";
            Keywords = "友情链接,自助链接";
            Description = "欢迎与本站建立友情链接!";
            if (CurrentCustomer != null)
            {
                Link = XpoSession.FindObject<G_FriendLink>(CriteriaOperator.Parse("SiteManagerId=?", CurrentCustomer));
            }
            if (Link == null) Link = new G_FriendLink(XpoSession);

            if (CurrentCustomer == null)
            {
                Tips = "请您先用QQ登录，再使用此功能。";
            }
            else if (IsPostBack)
            {
                Link.SiteManagerId = CurrentCustomer;
                Link.Title = Request.Form["txtTitle"].Trim();
                Link.Intro = Request.Form["txtIntro"].Trim();
                Link.Url = Request.Form["txtUrl"].Trim();
                Link.AskTime = DateTime.Now;
                Link.Save();

                Tips = String.Format(@"您的邀请已经提交成功！请将本站链接放置于贵站
                的首页显眼处，然后经本站确认后会将您的链接也放置在本站的首页。");
            }
            else
            {
                Tips = "感谢您登录本站！如果要邀请本站友情链接,请填写以下信息:";
            }
        }
    }
}